<template>
	<view>
		<view class="toubutx mainpadding" style="padding-bottom: 80rpx;">
			<view class="xiaobtext">可提现积分</view>
			<view class="margin_top2 flexleft">
				<!-- <view class="colour">￥</view> -->
				<view class="dbaitext">{{score}}</view>
			</view>
		</view>
		<view class="mainpadding">
			<view class="neirong">
				<view class="mainpadding ffffff radius ">
					<view class="notitletext">提现积分</view>
					<view class="flexbetween margin_top">
						<view class="" style="flex: 5;">
							<input type="number" class="daheitext" v-model="txprice">
						</view>
						<view class="huangsetext" style="flex: 1.1;" @click="alltx">全部提现
						</view>
					</view>
				</view>
				<!-- <view class="mainpadding_top ffffff radius flexbetween" @click="paytype=1">
					<view class="flexleft">
						<image src="@/static/image/system/wxicon.png" class="wximg margin_right" mode=""></image>
						<view class="titletext hei_text bold">微信</view>
					</view>
					<view class="nocheckaudio" v-show="paytype!=1"></view>
					<view class="checkaudio" v-show="paytype==1"></view>
				</view> -->
				<view class="mainpadding_top ffffff radius flexbetween" @click="paytype=2">
					<view class="flexleft">
						<image src="@/static/image/system/zhifub.png" class="wximg margin_right" mode=""></image>
						<view class="titletext hei_text bold">支付宝</view>
					</view>
					<view class="nocheckaudio" v-show="paytype!=2"></view>
					<view class="checkaudio" v-show="paytype==2"></view>
				</view>
				<view class="xiaohong margin_top">{{withdrawal_bz}}</view>
			</view>
		</view>
		<view class="posibottom mainpadding">
			<view class="xiaolan flexcenter" @click="tztxjl">提现记录</view>
			<view class="submitbtn margin_top" @click="tixianbtn">提现</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				show: false,
				paytype: 2,
				txprice: "",
				withdrawal_bz: "", //提现备注  
				type: 0, //0应用积分，1推广积分
				score: 0,
				userInfo: {},
			}
		},
		onLoad(options) {
			this.type = options.type
			this.beizhu()
			this.getinfo()
		},
		methods: {
			beizhu() { //提现备注
				let _this = this
				httpRequest.request('/api/index/getConfigInfo', 'GET').then(res => {
					this.withdrawal_bz = res.data.tx_notex
				})
			},
			getinfo() { //用户信息
				httpRequest.request('/api/user/index', 'GET', {}, false, false, true).then(res => {
					if (res.code == 1) {
						if (this.type == 1) {
							this.score = res.data.rec_score
						} else {
							this.score = res.data.yy_score
						}
						this.userInfo = res.data
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			// 跳转提现记录
			tztxjl() {
				uni.navigateTo({
					url: '/pages/mine/tixianjl?type=' + this.type
				})
			},
			tixianbtn() {
				if (this.userInfo.is_smrz == 1) {
					httpRequest.toast("未完成实名认证，请先完成实名认证")
					return false
				}
				if (this.txprice == "") {
					httpRequest.toast("请输入提现积分数量")
					return false
				}
				
				httpRequest.request('/api/user/addWithdrawal', 'GET', {
					score: this.txprice,
					type: this.paytype,
					ly_type: this.type == 1 ? 2 : 1
				}, false, false, true).then(res => {
					if (res.code == 0) {
						httpRequest.toast(res.msg);
					}
					if (res.code == -1 || res.code == -2) {
						httpRequest.toast(res.msg);
						setTimeout(() => {
							uni.navigateTo({
								url: '/pages/mine/shezhi'
							})
						}, 1000)
					}
					if (res.code == 1) {
						httpRequest.toast("24小时内到账请耐心等待");
						setTimeout(() => {
							uni.navigateBack(1)
						}, 1000)
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			alltx() { //全部提现
				this.txprice = this.score;
			},
		}
	}
</script>

<style lang="scss" scoped>
	.wximg {
		width: 32rpx;
		height: 32rpx;
		min-width: 32rpx;
	}

	.bighuangsetext {
		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #3478F5;
	}

	.toubutx {
		background: linear-gradient(90deg, #5A9DFF 0%, #3478F5 100%);
	}

	.colour {
		color: #fff;
	}

	.renzbtn {
		width: 291.5rpx;
		height: 74rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #fff;
		border-top: 1rpx solid #E7E7E7;
		// border-right:1rpx solid #E7E7E7;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		border-radius: 0 0 20rpx 0;
		color: #228DFF;
	}

	/deep/.u-radio-group {
		flex: none !important;
	}

	.quxiaobtn {
		border-radius: 0 0 0 20rpx;
		width: 291.5rpx;
		height: 74rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #fff;
		border-top: 1rpx solid #E7E7E7;
		border-right: 1rpx solid #E7E7E7;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.tanchuceng {
		padding: 40rpx 70rpx;
	}


	.querenbtn {
		border-radius: 40rpx;
		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		width: 328rpx;
		height: 64rpx;
		background-size: 100% 100%;
		display: flex;
		background-color: #3478F5;
		align-items: center;
		justify-content: center;
	}

	.hongstext {
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FF0303;
	}

	.huisetext {
		font-size: 26rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;
	}


	.xiahuax {
		padding-bottom: 30rpx;
		border-bottom: 2rpx solid rgba(0, 0, 0, 0.05);
	}

	.huangsetext {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #3478F5;
	}

	.sishitext {
		font-size: 40rpx;
		font-family: DIN Next LT Pro-Regular, DIN Next LT Pro;
		font-weight: 400;
		color: #333333;
	}

	.daheitext {
		font-size: 55rpx;
		font-family: DIN Next LT Pro-Regular, DIN Next LT Pro;
		font-weight: 500;
		color: #333333;
	}

	.neirong {
		position: relative;
		top: -80rpx;
	}

	.dbaitext {
		font-size: 40rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FFFFFF;
	}

	.xiaobtext {
		font-size: 24rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FFFFFF;
	}

	.margin_top7 {
		margin-top: 70rpx;
	}
</style>